package com.bustle.web;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

public class Report
{
  static public void error(String aMessage)
  {
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, aMessage, null));
    System.out.println(aMessage);
  }

  static public void error(String aMessage, Throwable aThrowable)
  {
    Throwable throwable = aThrowable;
    while (throwable.getCause() != null)
    {
      throwable = throwable.getCause();
    }
    FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, throwable.getMessage(), null));

    aThrowable.printStackTrace();
  }
}
